﻿using System;

class SevenlandNumbers
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 28 Dec 2012
        checked
        {
            int inputNumber = int.Parse(Console.ReadLine());
            int result = 0;
            int shift = 4;
            int biggerShift = 34;

            if (inputNumber < 666)
            {
                if (inputNumber % 10 == 6)
                {
                    result = inputNumber + shift;

                    if ((result > 100) && (result % 100 == 70))
                    {
                        int newResult = inputNumber + biggerShift;
                        Console.WriteLine(newResult);
                    }
                    else if (result / 10 == 7)
                    {
                        result = inputNumber + biggerShift;
                        Console.WriteLine(result);
                    }
                    else
                    {
                        Console.WriteLine(result);
                    }
                }
                else
                {
                    result = inputNumber + 1;
                    Console.WriteLine(result);
                }
            }
            else if (inputNumber == 666)
            {
                Console.WriteLine(1000);
            }
            else
            {
                Console.WriteLine("Wrong input");
            }                           
        }        
    }
}

